//
//  NotiTableViewCell.m
//  Findif
//
//  Created by Mac on 2018/12/10.
//  Copyright © 2018年 Cicel Chen. All rights reserved.
//

#import "NotiTableViewCell.h"

@interface NotiTableViewCell ()

@property (nonatomic, weak)UIView * whiteView;
@property (nonatomic, weak)UILabel * contentLabel;
@property (nonatomic, weak)UILabel * timeLabel;
@property (nonatomic, weak)UIImageView * isReadImageView;

@end

@implementation NotiTableViewCell


- (void)setModel:(NSNotiModel *)model{
    
    _model = model;
    
    self.contentLabel.text = model.notice_content;
//    self.timeLabel.text = [NSString stringWithFormat:@"%@",model.inputtime];
    int is_see = [model.is_see intValue];
    if (is_see == 0) {
        
        self.isReadImageView.hidden = NO;
    }else{
        
        self.isReadImageView.hidden = YES;
    }
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}

- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
//    self.backgroundColor = ZRWhiteColor;
    
    UIView * whiteView = [UIView new];
    
    whiteView.backgroundColor = ZRWhiteColor;
    whiteView.layer.cornerRadius = 5 * SCREENH6;
    whiteView.layer.masksToBounds = YES;
    
    self.whiteView = whiteView;
    
    [self.contentView addSubview:self.whiteView];
    
    UILabel * contentLabel = [UILabel new];
    
    contentLabel.textColor = ZRBlackColor;
    contentLabel.font = [UIFont systemFontOfSize:17 * SCREENH6];
//    contentLabel.numberOfLines = 0;
    
    self.contentLabel = contentLabel;
    
    [self.whiteView addSubview:self.contentLabel];
    
    
//    UILabel * timeLabel = [UILabel new];
//
//    timeLabel.textColor = [UIColor lightGrayColor];
//    timeLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
//    timeLabel.numberOfLines = 0;
//
//    self.timeLabel = timeLabel;
//
//    [self.whiteView addSubview:self.timeLabel];
    
    UIImageView * imageView = [UIImageView new];
    
    imageView.image = [UIImage imageNamed:@"Ellipse3"];
    
    self.isReadImageView = imageView;
    
    [self.whiteView addSubview:self.isReadImageView];
    
}


-(void)layoutSubviews{
    
    [self.whiteView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.contentView).offset(-15 * SCREENH6);
//        make.top.mas_equalTo(self.contentView).offset(5 * SCREENH6);
//        make.bottom.mas_equalTo(self.contentView).offset(-5 * SCREENH6);
        make.centerY.mas_equalTo(self.contentView);
        make.height.mas_equalTo(50 * SCREENH6);
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.whiteView).offset(10 * SCREENH6);
        make.trailing.mas_equalTo(self.whiteView).offset(-10 * SCREENH6);
//        make.top.mas_equalTo(self.whiteView).offset(10 * SCREENH6);
//        make.bottom.mas_equalTo(self.whiteView).offset(-30 * SCREENH6);
        make.centerY.mas_equalTo(self.whiteView);
    }];
    
//    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.trailing.mas_equalTo(self.contentLabel);
//        make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(5 * SCREENH6);
//    }];
    
    [self.isReadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self.whiteView.mas_trailing).offset(-5 * SCREENH6);
        make.top.mas_equalTo(self.whiteView).offset(5 * SCREENH6);
//        make.centerY.mas_equalTo(self.whiteView);
        make.height.width.mas_equalTo(8 * SCREENH6);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
